#!/usr/bin/make -f
# debian.rules file for slack-master
# $Id$
# Copyright 2004 Alan Sundell <alan@sundell.net>
# Based on the debian.rules file for rsync.
#   Copyright 1996 by Philip Hands.
#   Copyright 2001 Colin Walters <walters@debian.org>
# Based on the  sample debian.rules file - for GNU Hello (1.3).
#   Copyright 1994,1995 by Ian Jackson.
# I hereby give you perpetual unlimited permission to copy,
# modify and relicense this file, provided that you do not remove
# my name from the file itself.  (I assert my moral right of
# paternity under the Copyright, Designs and Patents Act 1988.)

# This is the debhelper compatibility version to use.
export DH_COMPAT=3

SHELL =	/bin/bash
INSTALL = install
INSTALL_FILE = $(INSTALL) -p    -o root -g root  -m  644
INSTALL_PROGRAM = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_SCRIPT = $(INSTALL) -p    -o root -g root  -m  755
INSTALL_DIR = $(INSTALL) -p -d -o root -g root  -m  755

# backwards compatibility stuff, from dpkg-architecture manpage
DEB_BUILD_ARCH := $(shell dpkg --print-installation-architecture)
DEB_BUILD_GNU_CPU := $(patsubst hurd-%,%,$(DEB_BUILD_ARCH))
ifeq ($(filter-out hurd-%,$(DEB_BUILD_ARCH)),)
DEB_BUILD_GNU_SYSTEM := gnu
else
DEB_BUILD_GNU_SYSTEM := linux
endif
DEB_BUILD_GNU_TYPE=$(DEB_BUILD_GNU_CPU)-$(DEB_BUILD_GNU_SYSTEM)

DEB_HOST_ARCH=$(DEB_BUILD_ARCH)
DEB_HOST_GNU_CPU=$(DEB_BUILD_GNU_CPU)
DEB_HOST_GNU_SYSTEM=$(DEB_BUILD_GNU_SYSTEM)
DEB_HOST_GNU_TYPE=$(DEB_BUILD_GNU_TYPE)

DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)

PACKAGE=slack-master
DESTDIR=$(CURDIR)/debian/$(PACKAGE)

configure: configure-stamp
configure-stamp:
	dh_testdir
# Add here commands to configure the package.
	touch configure-stamp

build: build-stamp

build-stamp: configure-stamp
	dh_testdir
	touch build-stamp

clean:
	dh_testdir
	rm -f build-stamp configure-stamp
	dh_clean

install: build
	dh_testdir
	dh_testroot
	dh_clean -k
	dh_installdirs

	$(INSTALL_SCRIPT) src/slack-rsyncd   $(DESTDIR)/usr/lib/slack-master
	$(INSTALL_SCRIPT) src/slack-update-source   $(DESTDIR)/usr/sbin
	$(INSTALL_FILE) src/slack-update-source.8   $(DESTDIR)/usr/share/man/man8
	$(INSTALL_FILE) src/slack-master.conf   $(DESTDIR)/etc
	$(INSTALL_FILE) src/slack-master.cron   $(DESTDIR)/etc/cron.d/slack-master
	$(INSTALL_DIR) $(DESTDIR)/DEBIAN
	(cd $(DESTDIR); find ./etc -type f | sed s,.,,) >> $(DESTDIR)/DEBIAN/conffiles

binary-indep: build install
	dh_testdir
	dh_testroot
	dh_installdocs README src/authorized_keys.example
	dh_installchangelogs
	dh_strip
	dh_compress
	dh_fixperms
	dh_installdeb
	dh_gencontrol
	dh_md5sums
	dh_builddeb

binary-arch: build install
# nothing to do

binary: binary-indep binary-arch
.PHONY: binary binary-arch binary-indep clean install configure
